#!/bin/bash

srv_name="logprocess"

chmod +x ./$srv_name

if pgrep -x $srv_name >/dev/null
then
    echo "${srv_name} is running"
    echo "shutting down ${srv_name}"
    if ps -a |grep $srv_name |awk '{print $1}'|xargs kill $1
       then
           echo "starting${srv_name}"
           ./$srv_name > /dev/null 2>&1 &
           echo "start ${srv_name} success"
    fi
else
    echo "starting ${srv_name}"
    ./${srv_name}>/dev/null 2>&1 &
    echo "start ${srv_name} success"
fi